package com.yungu.swift.assets.driver.service.impl;


import com.alibaba.dubbo.config.annotation.Service;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.yungu.swift.assets.driver.dao.DriverEvaluationMapper;
import com.yungu.swift.assets.driver.model.dto.DriverEvaluationDto;
import com.yungu.swift.assets.driver.model.param.AdminDriverEvaluationPageParam;
import com.yungu.swift.assets.driver.model.vo.DriverEvaluationDetailVo;
import com.yungu.swift.assets.driver.model.vo.DriverEvaluationInfoVo;
import com.yungu.swift.assets.driver.service.DriverEvaluationService;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.base.mapper.IMapper;
import com.yungu.swift.base.model.PageVo;
import com.yungu.swift.base.service.impl.BaseServiceImpl;
import com.yungu.swift.utils.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

@Service
public class DriverEvaluationServiceImpl extends BaseServiceImpl<DriverEvaluationDto> implements DriverEvaluationService {
    @Autowired
    private DriverEvaluationMapper driverEvaluationMapper;

    @Override
    protected IMapper<DriverEvaluationDto> getMapper() {
        return driverEvaluationMapper;
    }


    @Override
    public ResponseData<PageVo<DriverEvaluationInfoVo>> queryPageVo(AdminDriverEvaluationPageParam evaluationPageParam) {

        Map<String, Object> paraMap = MapUtils.convertObjToMap(evaluationPageParam);

        PageBounds pageBounds = new PageBounds(evaluationPageParam.getPageNum(), evaluationPageParam.getPageSize());
        PageList<DriverEvaluationInfoVo> pageList = driverEvaluationMapper.queryPageVo(paraMap, pageBounds);
        PageVo<DriverEvaluationInfoVo> pageVo = new PageVo(evaluationPageParam.getPageNum(), evaluationPageParam.getPageSize(),
                pageList.getPaginator().getTotalCount());
        pageVo.setItems(pageList);
        return ResponseData.buildSuccessResponse(pageVo);
    }


    @Override
    public ResponseData<List<DriverEvaluationInfoVo>> queryEvaluationInfo(AdminDriverEvaluationPageParam pageParam) {
        Map<String, Object> paraMap = MapUtils.convertObjToMap(pageParam);
        return ResponseData.buildSuccessResponse(driverEvaluationMapper.queryEvaluationInfo(paraMap));
    }



    @Override
    public ResponseData<List<DriverEvaluationDetailVo>> queryItemDetail(AdminDriverEvaluationPageParam pageParam) {
        Map<String, Object> paraMap = MapUtils.convertObjToMap(pageParam);
        return ResponseData.buildSuccessResponse(driverEvaluationMapper.queryItemDetail(paraMap));
    }
}
